package com.hariro.main;

import android.app.Application;
import android.content.Context;

import com.nostra13.universalimageloader.cache.disc.naming.Md5FileNameGenerator;
import com.nostra13.universalimageloader.core.DisplayImageOptions;
import com.nostra13.universalimageloader.core.ImageLoader;
import com.nostra13.universalimageloader.core.ImageLoaderConfiguration;
import com.nostra13.universalimageloader.core.assist.QueueProcessingType;
import com.qianfeng.project.R;

public class UILApplication extends Application {
	public static ImageLoader imageLoader = ImageLoader.getInstance();
	public static DisplayImageOptions options;

	@Override
	public void onCreate() {
		// TODO Auto-generated method stub
		super.onCreate();
		initImageLoader(getApplicationContext());
		options = new DisplayImageOptions.Builder()
				.showStubImage(R.drawable.common_loading_refresh)// 加载等待
																	// 时显示的图片
				.showImageForEmptyUri(R.drawable.default_ptr_rotate)// 加载数据为空时显示的图片
				.showImageOnFail(R.drawable.activity_again_request_icon)// 加载失败时显示的图片
				.cacheInMemory().cacheOnDisc()
				/**
				 * .displayer(new RoundedBitmapDisplayer(20))
				 **/
				.build();
	}

	public static void initImageLoader(Context context) {
		// This configuration tuning is custom. You can tune every option, you
		// may tune some of them,
		// or you can create default configuration by
		// ImageLoaderConfiguration.createDefault(this);
		// method.
		ImageLoaderConfiguration config = new ImageLoaderConfiguration.Builder(
				context).threadPriority(Thread.NORM_PRIORITY - 2)
				.denyCacheImageMultipleSizesInMemory()
				.discCacheFileNameGenerator(new Md5FileNameGenerator())
				.tasksProcessingOrder(QueueProcessingType.LIFO)
				// .enableLogging() // Not
				.build();
		// Initialize ImageLoader with configuration.
		ImageLoader.getInstance().init(config);
		// imageLoader.init(ImageLoaderConfiguration.createDefault(context));

	}
}
